
<?php
if (AuthComponent::user()!=NULL) {
    ?>
        <style>
            .navbar-inner {
                background: #FC3;
                padding-bottom: 5px;
                padding-top: 5px;
            }
            .navbar .nav > li > a {
                color: #999;
            }
            .navbar .nav .active > a, .navbar .nav .active > a:hover {
                color: black;
                text-decoration: none;
                background-color: #FFE52B;
            }
            .nav-collapse .nav > li > a:hover {
                background-color: #5E5555;
            }
            .navbar .btn-navbar {
                background: #5E5555;
            }
            .dropdown-menu li > a:hover,
            .dropdown-menu .active > a,
            .dropdown-menu .active > a:hover {
                color: white;
                text-decoration: none;
                background-color:  #5E5555;
            }
        </style>
    <?php
    $navItems = array(
        array(  'label' => 'Home',
            'active' => (($this->params['controller']=="users")&&($this->action=="display")&&($this->params['pass'][0]=="home")),
            'link' => '/users/home'),//aca se indica al controlador y de ser el caso el metodo que quiere indicar

        array(  'label' => 'Profile',
            'active' => (($this->params['controller']=="users")&&($this->action=="view")),
            'link' =>'/users/view/'.AuthComponent::user('id'))

    );
    
                       
  //  if ($this->Session->check('Organization')==false) { //ZP: ES NECESARIO ELEGIR UNA ORGANIZACION -->
          $arr=array( 'label' => 'Mis Organizaciones',
            'active' => (($this->params['controller']=="organizations")&&($this->action=="index")),
            'link' => '/organizations/index');
          array_push($navItems,$arr);
   // }
                            
    //NOTIFICACIONES
          $arr=array( 'label' => 'Solicitudes',
            'active' => (($this->params['controller']=="users")&&($this->action=="requests")),
            'link' => '/users/requests');
          array_push($navItems,$arr);


 } else {
     ?>
        <style>
            .navbar-inner {
            border-radius:0px;
            webkit-border-radius: 0px;
        }
        </style>
     <?php
     echo $this->element('templates/titulo');
     
     $navItems = array(
        array(  'label' => 'Home',
            'active' => ($this->params['controller']=='pages'),
            'link' => '/'),//aca se indica al controlador y de ser el caso el metodo que quiere indicar

        array(  'label' => 'About',
            'active' => false,
            'link' =>'/pages/about')

    );
     
     
 } 
?>


<div class="navbar">
    <div class="navbar-inner">
        <div class="container-fluid"> <!--  style="padding-top: 20px;" -->
            <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            </a>
            <a class="brand" href="/cake/">ScrumEgg</a>
            <?php 
                if (AuthComponent::user()!=NULL) {?>
                <div class="btn-group pull-right">
                    <a class="btn btn-dropdown-toggle" data-toggle="dropdown" href="#">
                        <i class="icon-user"></i> <?php echo AuthComponent::user('username')?> 
                        <span class="caret"></span>
                    </a>

                    <ul class="dropdown-menu">
                        <li><?php echo $this->Html->link("Profile","/users/view/".AuthComponent::user('id'));?> </li>
                        <li class="divider"></li>
                        <li><a href="#"><?php echo $this->Html->link("Sign Out","/users/logout");?></a></li>
                    </ul>
                    
                </div>
                <?php if ($this->Session->check('Organization')) {
                    $or=$this->Session->read('Organization'); 
                    ?>
                    <div class="btn-group pull-right">
                        <a class="btn btn-inverse" href="<?php echo $this->base;?>/organizations/view/<?php echo $or['Organization']['id'];?>">
                            <i class="icon-home icon-white"></i> 
                                <?php echo $or['Organization']['name'];?> 
                        </a>
    
                        <a class="btn btn-inverse dropdown-toggle" data-toggle="dropdown" href="#">
                            <span class="caret" style="height: 7px;"></span></a>
                        <ul class="dropdown-menu">
                            <li><a href="<?php echo $this->base;?>/projects/index/<?php echo $or['Organization']['id'];?>"> 
                                    <i class="icon-briefcase"></i> Projects
                                </a> 
                            </li>
                            <li class="divider"></li>
                            <li><a href="<?php echo $this->base;?>/organizations/index"> 
                                    <i class="icon-refresh"></i>Elegir otra
                                </a>
                            </li>
                        </ul>
                    </div>
                <?php } ?>
            <?php } else {?>
                    <?php 
                        if (($this->params['controller']=="users")&&($this->action=="login"))
                            echo $this->Html->link("Registrarse","/users/add",array('class'=>'btn pull-right'));
                        else
                            echo $this->Html->link("Ingresar","/users/login",array('class'=>'btn pull-right'));
                    ?> 
             <?php }?>
                
            <div class="nav-collapse">
                <ul class="nav">
                    <?php
                    foreach ($navItems as $navItem){
                        $activeStr = "";
                        if ($navItem['active']) $activeStr ="class='active'";
                        echo "<li ".$activeStr.">".$this->Html->link($navItem['label'],$navItem['link']).'</a></li>';
                    }
                    ?>
                    <li>
                        <a href="/z.palza/cake/css/chat/ajax-chat.html" target="_blank">Chat</a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>